import React, { Component } from 'react';
import BottomBar from 'com/BottomBar'
import {ClassifyStyled} from 'styled/Classify/ClassifyStyled'
import ClassifyHeader from 'com/Classify/ClassifyHeader'
import ClassifyList from 'com/Classify/ClassifyList'
import {classifyGetData} from 'api/classifyApi.js'
import {classify_sub_data} from 'store/actionCreator.js'
import {connect} from 'react-redux'


class Classify extends Component {

    constructor(props){
        super(props)
        this.state={
            classifyData:[]
        }
    }
    componentWillMount() {
        // 请求数据
        classifyGetData().then((ok)=>{
            this.props.dispatch(classify_sub_data(ok.data))
            this.setState({
                classifyData:this.props.state.classifyReducer.get("classifyData")
            })
            console.log(this.props.state.classifyReducer.get("classifyData"))
        }).catch((err)=>{
            console.log(err)
        })
    }
    render() {
        return (
            <ClassifyStyled>
                <ClassifyHeader/>
                <div className='classifyCon'>
                    <ClassifyList/>
                </div>
                <BottomBar/>
            </ClassifyStyled>
        );
    }
}

export default connect((state)=>({state}))(Classify);